<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>登录</title>
<link
	href="http://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap.min.css"
	rel="stylesheet">
<link rel="stylesheet" type="text/css" href="css/htmleaf-demo.css">
<link rel="stylesheet" type="text/css" href="css/center.css">
<link href="css/signin.css" rel="stylesheet">
<link rel="icon" type="image/x-icon" href="./images/bitbug_favicon.ico">
<link rel="icon" type="image/x-icon" href="./images/药.png" />
<script type="text/javascript" src="js/jquery-2.1.3.js"></script>
</head>
<body>
	<div class="htmleaf-container">
		<header class="htmleaf-header">
			<h1>欢迎使用设备管理系统</h1>
		</header>
		<div class="signin">
			<div class="signin-head">			
			</div>
			<form class="form-signin" role="form" action="login" method="post">
				<input type="text" class="form-control" id="userId" name="userId"
					placeholder="用户名" required autofocus />
				<input type="password" class="form-control" id="password"
					name="password" placeholder="密码" required />
				<div class="center">
					<input type="radio" name="userType" id="userType2" value="2">
					教师
					<input type="radio" name="userType" id="userType1" value="1">
					管理员
					<label id="tips" style="color:red"> </label>
				</div>
				<button type="button" id="login">登录</button>
			</form>
		</div>
	</div>
</body>
</html>
<script>
/* $('input:radio[name="userType"]').click(function() */
$("#login").click(function(){
	var val=$('input:radio[name="userType"]:checked').val()
	var userReqVo = {
		userId:$("#userId").val(),
        password:$("#password").val(),
		userType:val
        };
	var val=$('input:radio[name="userType"]:checked').val();
	if(val!=null) {
	$.ajax({
		type: "GET",
		url: "login",
		data: userReqVo,
		success: function (status) {
			if(status==-1){
				$("#tips").html(" * 用户或者密码错误");
				return ;
			}else{
				$("#tips").html(" 正在登录....");
				$('form').submit();
			}
		}
	});
	}else{
		$("#tips").html(" * 请选择登录角色");
		return ;
	}
});

</script>